package com.topideal.supplychain.hades.master.mapper;

import com.topideal.supplychain.hades.master.model.Project;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author xuxiaoyan
 * @date 2018-09-17 18:01
 */
@Mapper
public interface ProjectMapper {

    /**
     * 根据项目id或项目名搜索项目
     *
     * @param query
     * @return
     */
    @Select("<script> " +
            "select * "
            + "from project "
            + "<where>"
            + " <if test=\"query != null and query != '' \"> "
            + "and ( ID like concat('%',#{query},'%') or pname like concat('%',#{query},'%')) </if> "
            + " </where> "
            + " </script> ")
    List<Project> selectByIdOrName(@Param("query") String query);
}
